home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 October: Windmill on DISC / ADC Developer CD (1993-10) (''Windmill On DISC'')_iso / Dev.CD Oct 93.iso / System Software / U.S. System Software / System 7 Pro™ Beta 11 / Development Tools / Sample Code / Messaging Service Access Module / Internet PMSAM / Internet PMSAM source / ConvertAddress.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-19  |  1.7 KB  |  74 lines  |  [TEXT/MPS ]

  1. /*-------------------------------------------------------------------
  2.  
  3. AOCE Post Office Protocol (POP) / Simple Mail Transfer Protocol (SMTP)
  4. Mail Service Access Module
  5.  
  6. written by Steve Falkenburg-- MacDTS
  7. ©1991-1993 Apple Computer, Inc.
  8.  
  9. --------------
  10. change history
  11. --------------
  12.  
  13. SJF        02/19/93    update for beta build    b1
  14. SJF        10/29/92    update to a11            a11
  15. SJF        06/08/92    update to a8            a8
  16. SJF        02/15/92    first working version    a4.5
  17. SJF        10/16/91    initial coding            a3
  18.  
  19. ---------------------------------------------------------------------*/
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24.  
  25. #include <string.h>
  26.  
  27. #include <MacTCPCommonTypes.h>
  28. #include <AddressXLation.h>
  29. #include "ConvertAddress.h"
  30.  
  31. pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr);
  32.  
  33. // ConvertStringToAddr
  34. //
  35. // a MacTCP call to get a host's IP number, given the name of the host
  36. //
  37. OSErr ConvertStringToAddr(char *name,unsigned long *netNum)
  38. {
  39.     struct hostInfo hInfo;
  40.     OSErr result;
  41.     char done = 0x00;
  42.     extern Boolean gCancel;
  43.  
  44.     if ((result = OpenResolver(nil)) == noErr) {
  45.         result = StrToAddr(name,&hInfo,DNRResultProc,&done);
  46.         if (result == cacheFault)
  47.             while (!done)
  48.                 ; /* wait for cache fault resolver to be called by interrupt */
  49.         CloseResolver();
  50.         if ((hInfo.rtnCode == noErr) || (hInfo.rtnCode == cacheFault)) {
  51.             *netNum = hInfo.addr[0];
  52.             return noErr;
  53.         }
  54.         else
  55.             result = hInfo.rtnCode;
  56.     }
  57.     *netNum = 0;
  58.  
  59.     return result;
  60. }
  61.  
  62.  
  63. // DNRResultProc
  64. //
  65. // completion routine for MacTCP name resolver calls
  66. //
  67. pascal void DNRResultProc(struct hostInfo *hInfoPtr,char *userDataPtr)
  68. {
  69. #pragma unused (hInfoPtr)
  70.  
  71.     *userDataPtr = 0xff;    /* setting the use data to non-zero means we're done */
  72. }
  73.  
  74.